package com.iris.live.services.data.repositories;

import com.iris.live.services.data.models.Lsh活动KpiModel;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by ThinkPad on 2016/10/25.
 */
@Transactional
public interface Lsh活动KpiRepository extends JpaRepository<Lsh活动KpiModel, Integer>, JpaSpecificationExecutor<Lsh活动KpiModel> {

    @Modifying
    @Query("update Lsh活动KpiModel a set a.启用状态=?2 where a.kpi编号=?1")
    int updateStatusById(Integer id, String status);

    @Query("select a from Lsh活动KpiModel a where a.许可=?1 and a.kpi=?2")
    List<Lsh活动KpiModel> isExsitActKPI(String permit, String kpi);

    @Query("select a from Lsh活动KpiModel a where a.许可=?1")
    List<Lsh活动KpiModel> findByPermit(String permit);
}
